import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'node:path'
import postcsspxtorem from 'postcss-pxtorem'

// https://vitejs.dev/config/
export default defineConfig({
	plugins: [
		vue()
	],
	assetsInclude: ['**/*.jfif'], // 添加这一行
	build: {
		rollupOptions: {
			output: {
				manualChunks(id) {
					if (id.includes('myList.vue')) {
						return 'myList' // 为这个组件指定固定名称
					}
				}
			}
		}
	},
	css: {
		postcss: {
			plugins: [
				postcsspxtorem({
					rootValue: 37.5,
					propList: ['*'],
					selectorBlackList: ['.norem'],
					exclude: 'false' // 设置为 false 或函数返回 false
				})
			]
		}
	},
	// 确保 Vant 样式文件被处理
	optimizeDeps: {
		include: ['vant']
	},
	// 别名配置
	resolve: {
		alias: {
			'@': path.join(process.cwd(), './src'),
		}
	},
	server: {
		proxy: {
			'/jm': {
				target: 'http://test-api.saas.xm0592.com',
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/jm/, ""),
			}
		}
	},
})